<!-- wyf 2022-1-20 -->
<template>
  <a-textarea
    v-model:value="iptValue"
    :disabled="disabled"
    :default-value="defaultValue"
    :show-count="showCount"
    :maxlength="maxlength"
    :allow-clear="allowClear"
    :autosize="autosize"
    :placeholder="placeholder"
    @pressEnter="pressEnter"
  />
</template>

<script>
import { defineComponent, computed } from 'vue'
import { Textarea } from 'ant-design-vue'
export default defineComponent({
  name: 'ZTextarea',
  components: {
    ATextarea: Textarea
  },
  props: {
    value: {
      type: String,
      default: ''
    },
    defaultValue: {
      type: String,
      default: undefined
    },
    placeholder: {
      type: String,
      default: undefined
    },
    disabled: {
      type: Boolean,
      default: false
    },
    showCount: {
      type: Boolean,
      default: false
    },
    maxlength: {
      type: Number,
      default: 10000
    },
    allowClear: {
      type: Boolean,
      default: false
    },
    autosize: {
      type: [Boolean, Object],
      default: undefined
    }
  },
  setup(props, _ref) {
    const iptValue = computed({
      get() {
        return props.value
      },
      set(val) {
        _ref.emit('update:value', val)
      }
    })
    return {
      iptValue
    }
  },
  methods: {
    pressEnter(e) {
      this.$emit('pressEnter', e)
    }
  }
})
</script>
